package com.ketangpai.admin.controller;

import com.ketangpai.admin.entity.WorkComment;

import com.ketangpai.admin.entity.param.Param;
import com.ketangpai.admin.service.WorkCommentService;
import com.ketangpai.admin.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 作业评论表(WorkComment)表控制层
 *
 * @author makejava
 * @since 2023-06-14 01:17:50
 */
@RestController
@RequestMapping("workComment")
@Api(tags = "作业评论表")
public class WorkCommentController {
    /**
     * 服务对象
     */
    @Resource
    private WorkCommentService service;
    /**
     * 分页查询
     */
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public JsonResult<?> queryByPage(@RequestBody Param param) {
        Map<String,Object> map=service.selectList(param);
        return JsonResult.success(map);
    }

    /**
     * 新增数据
     */
    @ApiOperation("添加")
    @PostMapping("/insert")
    public JsonResult<?> insert(@RequestBody  WorkComment workComment){
        boolean result=  service.insert(workComment);
        if (result) {
            return JsonResult.success("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @ApiOperation("删除")
    @GetMapping("/delete/{id}")
    public JsonResult<?> delete(@PathVariable Integer id){
        boolean result=  service.deleteById(id);
        if (result) {
            return JsonResult.success("删除成功");
        }
        return JsonResult.error("删除失败");
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public JsonResult<?> update(@RequestBody WorkComment workComment){
        boolean result= service.update(workComment);
        if (result) {
            return JsonResult.success("编辑成功");
        }
        return JsonResult.error("编辑失败");
    }

}

